import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;

public class Test {


    static AtomicReference<Integer> atomicReference =new AtomicReference<>(100);



    public static void main(String[] args) {

        new Thread(()->{
            System.out.println(  atomicReference.compareAndSet(100, 101)+atomicReference.get().toString());

            System.out.println(  atomicReference.compareAndSet(101, 100)+atomicReference.get().toString());

        },"ti").start();


        new Thread(()->{

            try {
                Thread.sleep(100);

            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(  atomicReference.compareAndSet(100, 2019)+atomicReference.get().toString());

        },"t2").start();
    }













    /*
     *//*如果不加上这个if语句，编译器将提示"Initializer does not complete normally"并拒绝编译*//*
if（true）{
        System.out.println（Thread.currentThread（）+"init DeadLoopClass"）；
        while（true）{
        }
    }
}
}
public static void main（String[]args）{
        Runnable script=new Runnable（）{
public void run（）{
        System.out.println（Thread.currentThread（）+"start"）；
        DeadLoopClass dlc=new DeadLoopClass（）；
        System.out.println（Thread.currentThread（）+"run over"）；
        }
        }；
        Thread thread1=new Thread（script）；
        Thread thread2=new Thread（script）；
        thread1.start（）；
        thread2.start（）；*/

}
